<template>
  <div class="">
    <el-dialog
      @close="close"
      width="500px"
      append-to-body
      :title="$tt('label_remark')"
      :visible.sync="dialogVisible"
    >
      <ex_super_form ref="form" v-bind="option" label-width="80px">
      </ex_super_form>

      <span slot="footer" class="dialog-footer">
        <el-button @click="submit">{{$tt('label_confirm')}}</el-button>
        <el-button @click="dialogVisible = false">{{$tt('label_cancel')}}</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  components: {},
  props: {},
  data() {
    return {
      id: "",
      remark: "",
      dialogVisible: false,
    };
  },
  watch: {},
  computed: {
    option() {
      return {
        default: {
          text: this.remark,
        },
        model: [
          {
            grid: [
              [
                {
                  col: {
                    key: "text",
                    label: "label_purchase_content",
                    attrs: {
                      type: "textarea",
                    },
                  },
                },
              ],
            ],
          },
        ],
      };
    },
  },
  created() {},
  mounted() {},
  methods: {
    show({ id, remark }) {
      this.id = id;
      this.remark = remark;
      this.dialogVisible = true;
    },
    close() {
      this.$refs.form.resetFields();
      this.$emit("close");
    },
    submit() {
      const obj = this.$refs.form.getFormData();
      this.$ajax({
        url: '/oms-api/purchase/OmsPurchaseOrderRpc/updateRemark.json',
        type: "json",
        data: { id: this.id, remark: obj.text || "" },
        success: (res) => {
          if (res.code === 0) {
            this.dialogVisible = false;
            this.$message.success(this.$tt('tip_operate_success'))
            this.$refs.form.resetFields();
          }
        },
      });
    },
  },
  destroyed() {},
};
</script>

<style lang="less" scoped>
/deep/.el-dialog__body {
  padding: 0 20px;
}
.title {
  margin: 15px 10px;
}
</style>